package ru.ifmo.croak.impl.stress.query.team1;

import java.util.Random;

/**
 * @author Roman Kolganov
 * 26.05.11
 */
public class SafeRandom {

    private SafeRandom() {
    }

    public static int nextInt(Random rand, int limit) {
        return rand != null ? rand.nextInt(limit) :
                (int) (Math.random() * limit);
    }

    public static boolean nextBoolean(Random rand, int trueInvProb) {
        return nextInt(rand, trueInvProb) == 0;
    }

    public static int nextInt(Random rand, int min, int max) {
        return min + nextInt(rand, max - min);
    }
}
